package com.iss.apartmentmanage.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.iss.apartmentmanage.entity.User;
import com.iss.apartmentmanage.mapper.UserMapper;
import com.iss.apartmentmanage.model.UserWithRole;
import com.iss.apartmentmanage.model.UserWithUserInfo;
import com.iss.apartmentmanage.service.UserService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    UserMapper mapper;
    public UserWithRole login(User user){
        UserWithRole login = mapper.login(user);
        return login;
    }

    @Override
    public Integer insertUser(User user) {
        int count = 0;
        if(StringUtils.isNotEmpty(user.getUName())){
            if(StringUtils.isNotEmpty(user.getUPwd())){
                count  = mapper.insert(user);
            }
        }
        return count;
    }
    @Override
    public Integer getUserIdByUserName(User user) {
        Integer userId = 0;
        if(StringUtils.isNotEmpty(user.getUName())) {
            userId  = mapper.getUserIdByUserName(user.getUName());
        }
        return userId;
    }
}
